<?php 
if (!isset($_SESSION)) {
  session_start();
}
define("CCTRL", "ordertour");
define("CCTRLNAME", "ordertour");
define("TOKEN", "9d3a33d52a2f8047f75af4fd71d2cf45");
include APPPATH . 'libraries/defu.php';
class ordertour extends CI_Controller  {

        /**
        * Index Page for this controller.
        *
        * Maps to the following URL
        * 		http://example.com/index.php/welcome
        *	- or -  
        * 		http://example.com/index.php/welcome/index
        *	- or -
        * Since this controller is set as the default controller in 
        * config/routes.php, it's displayed at http://example.com/
        *
        * So any other public methods not prefixed with an underscore will
        * map to /index.php/welcome/<method_name>
        * @see http://codeigniter.com/user_guide/general/urls.html
        */
       protected $configs;
       function __construct()
        {
            parent::__construct();
            $this->load->helper('url');
            $this->load->model('backend/order_model');
            $this->order_model=new order_model();
            $this->load->model('colmod/ordertour_colmod');
            $this->colModel=new ordertour_colmod();
            $this->load->library('smarty3');
            $this->smarty=new CI_Smarty3();
            $this->smarty->error_reporting = E_ALL & ~E_NOTICE;
            if(!isset($_SESSION["ADP"][CCTRL]["display"]))$_SESSION["ADP"][CCTRL]["display"]=0;
        }
        function index(){
            if(!isset($_SESSION["ADP"]["USER"])){
                $this->smarty->display("backend/00_login"); 
                return;
            }
            if(!checkAuthority(CCTRLNAME)){
                $this->smarty
                        ->assign('_SESSION', $_SESSION)
                        ->display("backend/00_accessdenied");
                return;
            }
            $this->smarty
                    ->assign('_SESSION', $_SESSION)
                    ->display("backend/".CCTRL."/".CCTRL);
        }
        function detail($_id=""){
            $_oprs=$this->order_model->get($_id);
            $this->smarty
                    ->assign('_SESSION', $_SESSION)
                    ->assign('order_detail', $_oprs)
                    ->display("backend/".CCTRL."/01_order_detail");
        }
        function gridscript(){
            //unset($_SESSION["ADP"][CCTRL."-JQX"]);
            if(isset($_SESSION["ADP"][CCTRL."-JQX"]["colModel"]))
                $colModel=$_SESSION["ADP"][CCTRL."-JQX"]["colModel"];
            else{
                $colModel=$this->colModel->get();
                $_SESSION["ADP"][CCTRL."-JQX"]["colModel"]=$colModel;
            }
            header("Content-type:text/javascript");
            $this->smarty
                    ->assign("colModel", $colModel)
                    ->assign("display",$_SESSION["ADP"][CCTRL]["display"])
                    ->display("backend/00_base/grid_classic");
        }
        function handleEvent(){
            header("Content-type:text/javascript");
            $this->smarty
                    ->display("backend/".CCTRL."/handleEvent");
        }
        function binding(){
            $data_rows=array();
            $result=$this->order_model->binding_order_tour();
            $data[] = array(
                'TotalRows' => $result['total_rows'],
                'Rows' => $result['rows']
            );
            echo json_encode($data);
        }
        
}
?>
